<?php
  if(!isset($this->document->journal_install)) die('');
  require_once DIR_TEMPLATE . '/journal/template/common/Mobile_Detect.php' ;
  $detect = new Mobile_Detect();
  function print_menu($data, $child = false, $mobile_menu, $is_mobile) {
    $res = "";
    foreach ($data as $categ) {
      $sub = print_menu($categ['subcategs'], true, $mobile_menu, $is_mobile);
      $res .= $is_mobile && !$child ? '<li class="menu-hide">' : "<li>";
      $href = $categ['href'] ? 'href="' . $categ['href'] . '"' : '';
      if ($sub) {
        $res .= '<a ' . $href . '>' . $categ['name'] . "<span></span></a>";
        $res .= $sub;
      } else {
        $res .= '<a ' . $href . '>' . $categ['name'] . "</a>";
      }
      $res .= "</li>";
    }
    if ($res) {
      if ($child) return $is_mobile ? '<ul class="menu-hide">' . $res . '</ul>' : "<ul>" . $res . "</ul>";
      return '
        <ul class="sf-menu">
          <li class="open">
           <span class="menu-icon">
              <span></span>
              <span></span>
              <span></span>
            </span>' . $mobile_menu . '</li>
          ' . $res . '
        </ul>
      ';
    }
    return '';
  }
?>
<!DOCTYPE html>
<html dir="<?php echo $direction; ?>" lang="<?php echo $lang; ?>" class="theme_<?php echo $this->document->journal_active_theme; ?> <?php echo $this->document->journal_custom_blocks_count; ?>">
<head>
<?php if (isset($this->document->journal_responsive_design) && $this->document->journal_responsive_design === 'yes'): ?>
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="Public">
<?php endif; ?>
<?php $is_responsive = isset($this->document->journal_responsive_design) && $this->document->journal_responsive_design === 'yes'; ?>
<meta charset="UTF-8">
<title><?php 
if (strpos($title,'Woman Shop: ') !== false) {
    echo $title;
} else {
	echo $title.' | Woman Shop';
}
?></title>
<base href="<?php echo $base; ?>" >
<?php if ($description) { ?>
  <meta name="description" content="<?php echo $description; ?>">
<?php } ?>
<?php if ($keywords) { ?>
  <meta name="keywords" content="<?php echo $keywords; ?>">
<?php } ?>
<?php if ($filter_params) { ?>
  <meta name="robots" content="noindex, follow">
<?php } ?>
<?php if ($home_page) { ?>
  <link href="http://womanshop.bg" rel="canonical">
<?php } ?>
<?php if ($icon) { ?>
  <link href="<?php echo $icon; ?>" rel="icon">
<?php } ?>
<?php foreach ($links as $link) { ?>
  <link href="<?php echo $link['href']; ?>" rel="<?php echo $link['rel']; ?>" >
<?php } ?>
<?php foreach ($styles as $style) { ?>
  <link rel="<?php echo $style['rel']; ?>" type="text/css" href="<?php echo $style['href']; ?>" media="<?php echo $style['media']; ?>" >
<?php } ?>

<link href='http://fonts.googleapis.com/css?family=Open+Sans+Condensed:300&amp;subset=latin,cyrillic' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="catalog/view/theme/journal/stylesheet/style.css">

<?php if (isset($this->document->journal_wide_layout) && $this->document->journal_wide_layout === 'yes'): ?>
<script type="text/javascript">var WIDE_LAYOUT = true;</script>
<link rel="stylesheet" type="text/css" href="catalog/view/theme/journal/stylesheet/wide.css">

<?php else: ?>
  <script type="text/javascript">var WIDE_LAYOUT = false; </script>
<?php endif; ?>

<link rel="stylesheet" type="text/css" href="catalog/view/theme/journal/stylesheet/superfish.css" >
<link rel="stylesheet" type="text/css" href="catalog/view/theme/journal/stylesheet/blog_journal.css">


<link rel="stylesheet" type="text/css" href="catalog/view/javascript/jquery/ui/themes/ui-lightness/jquery-ui-1.8.16.custom.css" >
<link rel="stylesheet" type="text/css" href="catalog/view/javascript/jquery/colorbox/colorbox.css" media="screen" >


<?php if(isset($this->document->journal_stepper_input) && $this->document->journal_stepper_input === 'yes'):?>
<link rel="stylesheet" type="text/css" href="catalog/view/theme/journal/stylesheet/jquery.fs.stepper.css">
<script type="text/javascript" src="catalog/view/javascript/journal/jquery.fs.stepper.min.js"></script>
<?php endif; ?>

<link rel="stylesheet" type="text/css" href="catalog/view/theme/journal/stylesheet/responsive.css">
<script>
var responsive_design = true;
var CLOUD_ZOOM_TYPE = '<?php echo isset($this->document->journal_cloud_zoom_inner) && $this->document->journal_cloud_zoom_inner === "yes" ? "inner" : ""; ?>';
</script>

<link rel="stylesheet" type="text/css" href="catalog/view/javascript/journal/pnotify/jquery.pnotify.default.css">


<!--[if lt IE 9]><script src="//ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script><![endif]-->
<!--[if IE]><script src="//stringencoders.googlecode.com/svn-history/r230/trunk/javascript/base64.js"></script><![endif]-->
<!--[if IE]><script>if (!window.atob) window.atob = base64.decode;</script><![endif]-->



<!-- Larger logo -->
<?php if (isset($this->document->journal_larger_logo) && $this->document->journal_larger_logo === 'yes'
  && isset($this->document->journal_wide_layout) && $this->document->journal_wide_layout === 'no'): ?>
<link rel="stylesheet" type="text/css" href="catalog/view/theme/journal/stylesheet/larger_logo.css" />
<script>$(document).ready(function(){$('header').removeClass('header_ii');$('html').addClass('larger-logo');});</script>
<?php endif; ?>

<?php if (isset($this->document->journal_larger_logo) && $this->document->journal_larger_logo === 'yes'
  && isset($this->document->journal_wide_layout) && $this->document->journal_wide_layout === 'yes'): ?>
<link rel="stylesheet" type="text/css" href="catalog/view/theme/journal/stylesheet/larger_logo_wide_layout.css" />
<script>$(document).ready(function(){$('header').removeClass('header_ii');$('html').addClass('larger-logo');});</script>
<?php endif; ?>
<!-- End Larger logo -->


<?php if (isset($this->document->journal_product_page_desc) && $this->document->journal_product_page_desc === 'no'
       && isset($this->document->journal_product_page_price) && $this->document->journal_product_page_price === 'no'
       && isset($this->document->journal_product_page_options) && $this->document->journal_product_page_options === 'no'
       && isset($this->document->journal_product_page_cart) && $this->document->journal_product_page_cart === 'no'): ?>


<?php endif; ?>
<!-- End Catalog Mode -->
<meta name="google-site-verification" content="J9mKxqsCWYB1YZirLzlw4LYFSteMTy-Wcbo4ZsL1ceg" />
</head>
<body>

<script src="catalog/view/javascript/jquery/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="catalog/view/javascript/journal/pnotify/jquery.pnotify.min.js"></script>
<script type="text/javascript">
    function custom_notifier(message) {
      var $temp = $('<div>' + message + '</div>');
      var $title = $temp.find('a').last().prev();
      var timeout = '<?php echo isset($this->document->journal_product_notification_timeout) && is_numeric($this->document->journal_product_notification_timeout) ? $this->document->journal_product_notification_timeout : 1700; ?>';
      $.pnotify({
        title: $title.html(),
        delay: parseInt(timeout),
        text: message,
        type: 'success',
      });
    }
    window.custom_notifier = custom_notifier;
</script>
<?php foreach ($scripts as $script) { ?>
<script src="<?php echo $script; ?>"></script>
<?php } ?>

<script type="text/javascript">
  var DECIMAL_POINT = '<?php echo $this->document->journal_decimal_point; ?>';
</script>
<script src="catalog/view/javascript/journal/jquery.autocomplete.min.js"></script>
<script src="catalog/view/javascript/journal/journal.js"></script>
<?php echo $google_analytics; ?>

<header <?php echo isset($this->document->journal_header_type) && $this->document->journal_header_type === 'yes' ? 'class="header_ii"' : ''; ?>>
  <div class="top-header"></div>
  <div id="journal-header">
        <?php if ($logo) { ?>
        <div id="logo"><a href="<?php echo $home; ?>">
          <img src="catalog/view/theme/journal/images/logo.svg" title="<?php echo $name; ?>" alt="<?php echo $name; ?>"  onerror="this.onerror=null; this.src='catalog/view/theme/journal/images/logo.png'"/></a>
        </div>
        <?php } ?>

        <div class="top-links">
          <?php if(isset($this->document->journal_top_menu)): ?>
          <?php foreach ($this->document->journal_top_menu as $menu_item): ?>
          <?php $target = $menu_item['new_window'] ? 'target="_blank"' : ''; ?>
          <?php $img = $menu_item['img'] ? '<img src="' . $menu_item['img'] .'" title="' . $menu_item['name'] .'" alt="' . $menu_item['name'] .'" />' : ''; ?>
          <?php if ($menu_item['href']): ?>
          <a class="link" href="<?php echo $menu_item['href']; ?>" <?php echo $target; ?>><?php echo $img . '<span>' . $menu_item['name'] . '</span>'; ?></a>
          <?php else: ?>
          <a class="no-link"><?php echo $img . '<span>' . $menu_item['name'] . '</span>'; ?></a>
          <?php endif; ?>
          <?php endforeach; ?>
          <?php endif; ?>

          <?php if (!isset($this->document->journal_top_menu) || count($this->document->journal_top_menu) === 0): ?>
          <a class="link" href="<?php echo $home; ?>"><?php echo $text_home; ?></a>
          <a class="link" href="<?php echo $wishlist; ?>" id="wishlist-total"><?php echo $text_wishlist; ?></a>
          <a class="link" href="<?php echo $account; ?>"><?php echo $text_account; ?></a>
          <?php endif; ?>
        </div>

        <?php if(!$is_responsive || !$detect->isMobile() || ($detect->isMobile() && $detect->isTablet())): ?>
        <div class="cart">
            <?php echo $cart; ?>
        </div>
        <?php endif; ?>

        <div class="welcome">
            <?php if (strlen($language) > 0): ?>
            	<?php echo $language; ?>           
            <?php endif; ?>
            <?php echo $currency; ?>
          <div id="welcome">
            <?php if (!$logged) { ?>
            <?php echo $text_welcome; ?>
            <?php } else { ?>
            <?php echo $text_logged; ?>
            <?php } ?>
          </div>
        </div>


        <div id="search">
           <div class="button-search"></div>
          <?php if (isset($filter_name)): ?>

            <?php if ($filter_name) { ?>
            <input type="text" name="filter_name" value="<?php echo $filter_name; ?>" />
            <?php } else { ?>
            <input type="text" name="filter_name" value="<?php echo $text_search; ?>" onclick="this.value = '';" onkeydown="this.style.color = '#000000';" />
            <?php } ?>

          <?php else: ?>

          <input type="text" name="search" placeholder="<?php echo $text_search; ?>" value="<?php echo $search; ?>" />

          <?php endif; ?>
        </div>

        <?php if($is_responsive && $detect->isMobile() && !$detect->isTablet()): ?>
        <div class="cart">
            <?php echo $cart; ?>
        </div>
        <?php endif; ?>


	<div class="modules">
    <?php foreach ($modules as $module) { ?>
 		<?php echo $module; ?>
    <?php } ?>
    </div>

<!-- navigation starts -->
    <nav class="menu">
    
    <?php $super_class = $detect->isMobile() && $is_responsive ? "mobile-nav" : ""; ?>
    <?php $super_class_hide = $detect->isMobile() && $is_responsive ? "class='menu-hide'" : ""; ?>
    
    <?php if(isset($this->document->journal_mega_menu)): ?>
      <div id="super-menu">
      <ul class='super-menu <?php echo $super_class; ?>'>
    
           <li class="open">
           <span class="menu-icon">
              <span></span>
              <span></span>
              <span></span>
            </span>
            <?php echo isset($this->document->journal_mobile_menu_title2) && $this->document->journal_mobile_menu_title2 ? $this->document->journal_mobile_menu_title2 : 'Menu'; ?>
          </li>
    
      <?php foreach ($this->document->journal_mega_menu as $menu_item): ?>
        <li <?php echo $super_class_hide; ?> >
          <?php if (isset($menu_item['link']) && $menu_item['link']): ?>
            <a href="<?php echo $menu_item['link']; ?>" <?php echo $menu_item['new_window']; ?> ><?php echo $menu_item['name']; ?><span></span></a>
          <?php else: ?>
            <a href="javascript:;"><?php echo $menu_item['name']; ?><span></span></a>
          <?php endif; ?>
          <?php if ($menu_item['type'] === 'megamenu' && count($menu_item['items'])): ?>
          <div class="mega-menu">
            <?php foreach ($menu_item['items'] as $item): ?>
              <?php $no_image_class = $menu_item['show_images'] ? '' : 'item-no-image'; ?>
              <div class="mega-menu-item <?php echo $no_image_class; ?>">
                <a class="mega-menu-top" data-img="<?php echo $item['image']; ?>" href="<?php echo $item['link']; ?>"><?php echo $item['name']; ?></a>
                <ul class='mega-menu-ul'>
                  <?php $index = 0; ?>
                  <?php foreach ($item['subcategs'] as $subcateg): ?>
                    <?php if (is_numeric($menu_item['maxSubItems']) && $menu_item['maxSubItems'] > 0 && $index >= $menu_item['maxSubItems']) break; ?>
                    <li><span></span><a class="mega-menu-sub" data-img="<?php echo $subcateg['image']; ?>" href="<?php echo $subcateg['link']; ?>"><?php echo $subcateg['name']; ?></a></li>
                  <?php $index++; endforeach; ?>
                  <?php if(is_numeric($menu_item['maxSubItems']) && $menu_item['maxSubItems'] > 0 && count($item['subcategs']) > $index): ?>
                    <li class="show-more"><span></span><a class="mega-menu-sub" href="<?php echo $item['link']; ?>"><?php echo $menu_item['moreText']; ?></a></li>
                  <?php endif; ?>
                </ul>
                <?php if($menu_item['show_images']): ?>
                <img src="<?php echo $item['image']; ?>" alt="" />
                <?php endif; ?>
    
              </div>
            <?php endforeach; ?>
          </div>
          <?php endif; ?>
    
          <?php if ($menu_item['type'] === 'brands' && count($menu_item['items'])): ?>
          <div class="brands-menu">
            <?php foreach ($menu_item['items'] as $item): ?>
              <?php $no_image_class = $menu_item['show_images'] ? '' : 'item-no-image'; ?>
              <div class="brands-menu-item <?php echo $no_image_class; ?>">
                <a class="brands-menu-top" href="<?php echo $item['link']; ?>"><?php echo $item['name']; ?></a>
                <?php if($menu_item['show_images']): ?>
                <img src="<?php echo $item['image']; ?>" onclick="location='<?php echo $item['link']; ?>';" />
                <?php endif; ?>
              </div>
            <?php endforeach; ?>
            <div class="clearfix"> </div>
          </div>
          <?php endif; ?>
    
          <?php if ($menu_item['type'] === 'customblock'): ?>
            <ul class="custom-block-menu">
              <li><?php echo $menu_item['text']; ?></li>
            </ul>
          <?php endif; ?>
    
          <?php if ($menu_item['type'] === 'simplemenu' && count($menu_item['items'])): ?>
            <ul class="dropdown-menu">
              <?php foreach ($menu_item['items'] as $item): ?>
                <?php if($item['link']): ?>
                <li><a href="<?php echo $item['link']; ?>" <?php echo $item['new_window']; ?>><?php echo $item['name']; ?></a></li>
                <?php else: ?>
                <li><a href="javascript:;" <?php echo $item['new_window']; ?>><?php echo $item['name']; ?></a></li>
                <?php endif; ?>
              <?php endforeach; ?>
            </ul>
          <?php endif; ?>
    
          <?php if ($menu_item['type'] === 'products' && count($menu_item['items'])): ?>
        <div class="product-menu">
          <?php foreach ($menu_item['items'] as $item): ?>
            <div class="product-menu-item">
              <img src="<?php echo $item['image']; ?>" onclick="location='<?php echo $item['link']; ?>';" />
              <a class="product-menu-name" href="<?php echo $item['link']; ?>" title="<?php echo $item['name']; ?>"><?php echo $item['name']; ?></a>
              <div class="price">
                <?php if (!$item['special']) { ?>
                <?php echo $item['price']; ?>
                <?php } else { ?>
                <div class="sale"></div>
                <span class="price-old"><?php echo $item['price']; ?></span> <span class="price-new"><?php echo $item['special']; ?></span>
                <?php } ?>
              </div>
              <input type="button" class="button" value="<?php echo $item['add_to_cart']; ?>" onclick="addToCart('<?php echo $item['product_id']; ?>')" />
            </div>
          <?php endforeach; ?>
          <div class="clearfix"> </div>
        </div>
      <?php endif; ?>
    </li>
  <?php endforeach; ?>
  </ul>

  <?php if (isset($this->document->journal_mega_menu_animation)): ?>
  <?php if($this->document->journal_mega_menu_animation == '0'): ?>
      <script>
          $(document).ready(function(){
            $('.super-menu > li').hoverIntent( function(){
              console.log('xx');
              if($('.super-menu').hasClass('mobile-nav')) return;
              $('> div, > ul', this).css({'visibility': 'visible','opacity' : '1'});
            }, function(){
              if($('.super-menu').hasClass('mobile-nav')) return;
              $('> div, > ul', this).css({'visibility': 'hidden','opacity' : '0'});
            });
      });
    </script>
  <?php endif;?>
  <?php if($this->document->journal_mega_menu_animation == '1'): ?>
    <script>
        $(document).ready(function(){
          $('.super-menu > li').hoverIntent(function(){
            if($('.super-menu').hasClass('mobile-nav')) return;
            $('> div, > ul', this).hide();
            $('> div, > ul', this).css({'visibility': 'visible','opacity' : '1'});
            $('> div, > ul', this).stop(true, true).slideDown(250);
          }, function(){
            if($('.super-menu').hasClass('mobile-nav')) return;
            $('> div, > ul', this).stop(true, true).slideUp(150);
          });
        });
    </script>
  <?php endif;?>

<?php endif; ?>

</div>
<?php else: ?>
<?php if(
              isset($this->document->journal_categories_menu_extended)
              && $this->document->journal_categories_menu_extended
              && isset($this->document->journal_categories_menu_extended_status)
              && $this->document->journal_categories_menu_extended_status === 'yes'): ?>
      <div id="menu">
      <?php echo print_menu($this->document->journal_categories_menu_extended, false, isset($this->document->journal_mobile_menu_title2) && $this->document->journal_mobile_menu_title2 ? $this->document->journal_mobile_menu_title2 : 'Menu', $is_responsive && $detect->isMobile() && !$detect->isTablet()) ?>
      </div>
      <?php else: ?>
        <?php if ($categories) { ?>
        <div id="menu">
          <ul <?php echo $detect->isMobile() && $is_responsive ? 'class="mobile-nav"' : ''; ?>>
            <li class="open">
             <span class="menu-icon">
                <span></span>
                <span></span>
                <span></span>
              </span>
              <?php echo isset($this->document->journal_mobile_menu_title2) && $this->document->journal_mobile_menu_title2 ? $this->document->journal_mobile_menu_title2 : 'Menu'; ?>
            </li>
            <?php foreach ($categories as $category) { ?>
            <li <?php echo $super_class_hide; ?>>
              <a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
              <?php if ($category['children']) { ?>
              <div>
                <?php for ($i = 0; $i < count($category['children']);) { ?>
                <ul>
                  <?php $j = $i + ceil(count($category['children']) / $category['column']); ?>
                  <?php for (; $i < $j; $i++) { ?>
                  <?php if (isset($category['children'][$i])) { ?>
                  <li>
                    <a href="<?php echo $category['children'][$i]['href']; ?>">
                      <?php echo $category['children'][$i]['name']; ?>
                    </a>
                  </li>
                  <?php } ?>
                  <?php } ?>
                </ul>
                <?php } ?>
              </div>
              <?php } ?>

            </li>
            <?php } ?>
            <?php if(isset($this->document->journal_categories_menu)): ?>
            <?php foreach ($this->document->journal_categories_menu as $menu_item): ?>
            <li>
            <?php $target = $menu_item['new_window'] ? 'target="_blank"' : ''; ?>
            <?php if ($menu_item['href']): ?>
            <a href="<?php echo $menu_item['href']; ?>" <?php echo $target; ?>><?php echo $menu_item['name']; ?></a>
            <?php else: ?>
            <a><?php echo $menu_item['name']; ?></a>
            <?php endif; ?>

            <?php if (count($menu_item['subcategs'])): ?>
            <div>
              <ul>
              <?php foreach ($menu_item['subcategs'] as $submenu_item): ?>
                <li>
                <?php $target = $submenu_item['new_window'] ? 'target="_blank"' : ''; ?>
                <?php if ($submenu_item['href']): ?>
                <a href="<?php echo $submenu_item['href']; ?>" <?php echo $target; ?>> <?php echo $submenu_item['name']; ?></a>
                <?php else: ?>
                <a> <?php echo $submenu_item['name']; ?></a>
                <?php endif; ?>
              </li>
              <?php endforeach; ?>
              </ul>
            </div>
            <?php endif; ?>

            </li>
            <?php endforeach; ?>
            <?php endif; ?>
          </ul>
        </div>
        <?php } ?>
      <?php endif; ?>
<?php endif; ?>



</nav>
</div> <!-- End #journal-header -->

</header>
<div id="container">
  <?php if (isset($error)): ?>
<?php if ($error) { ?>
  <div class="warning"><?php echo $error ?><img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>
<?php } ?>
<?php endif; ?>
<div id="notification"></div>